const Koa = require('koa')

const koaBody = require('koa-body')

const KoaRouter = require('koa-router')

const KoaStaticCache = require('koa-static-cache')

const server = new Koa();
const router = new KoaRouter()

// 静态资源处理
server.use(KoaStaticCache({
    prefix:"/public",
    dir:"./src",
    gzip:true,
    dynamic:true
}))


// 指定一个url匹配
router.get('/', async (ctx) => {
    ctx.type = 'html';
    ctx.body = '<h1>hello world!</h1>';
})

server.use(router.routes())

server.listen(8000, () => {
    console.log(`服务启动了 http://localhost:8000/
        http://192.168.10.122:8000
    `)
})
